/*
 * precompile.h
 *
 *  Created on: 16-02-2012
 *      Author: glu
 */

#ifndef PRECOMPILE_H_
#define PRECOMPILE_H_

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_ttf.h>
#include <string>
#include <iostream>

#define TILES_COLUMNS_COUNT 14
#define TILES_ROWS_COUNT 10

#define TILE_HEIGHT 50
#define TILE_WIDTH 50

class Global {
public:
	static SDL_Surface* backgroundGlobal;

	static SDL_Surface* screen;

	static SDL_Surface* loadImage(std::string filename){
		SDL_Surface* loadedImage = NULL;
		SDL_Surface* optimizedImage = NULL;

		loadedImage = IMG_Load(filename.c_str() );
		if(loadedImage != NULL){
			optimizedImage = SDL_DisplayFormat(loadedImage);

			SDL_FreeSurface(loadedImage);
			if(optimizedImage != NULL){
				Uint32 colorkey = SDL_MapRGB(optimizedImage->format, 0x80, 0xFF, 0xFF);
				SDL_SetColorKey(optimizedImage, SDL_SRCCOLORKEY, colorkey);
			}
		}
		return optimizedImage;
	}

	static void applySurface( int xOffset, int yOffset, SDL_Surface* src, SDL_Surface* dst, SDL_Rect* clip=NULL){
		SDL_Rect rectOffset;
		rectOffset.x = xOffset;
		rectOffset.y = yOffset;

		SDL_BlitSurface(src, clip, dst, &rectOffset);
	}
};

enum GameStates {
	NoState, Intro, Menu, Battle, ExitState
};

#endif /* PRECOMPILE_H_ */
